public class LoanCalculator {
    int a,m;
    double y,avgCap,avgInt;
    LoanCalculator(int a,int b,double y){
        this.a=a;
        this.m=b;
        this.y=y;
    }
    void avgInterest(){
        avgCap = (m+1)*a*(y/12)/2;
    }
    void avgCaption(){
        double n = Math.pow(1+(y/12), m);
        avgInt = m*a*(y/12)*n/(n-1)-a;
    }
    void print(int type){
        if (type == 1) {
            System.out.println("等额本金："+avgCap);
        }
        if (type == 2) {
            System.out.println("等额本息："+avgInt);
        }
    }
}
